<?php
class FileUploadController extends CController
{
	public $defaultAction='create';
	
	public function actionCreate()
	{
		$model=new FileUploadForm;
		
        if(isset($_POST['FileUploadForm']))
        {
            $model->attributes=$_POST['FileUploadForm'];
            $model->image=CUploadedFile::getInstance($model,'image');
            $filename = 'uploads/'.$model->image->name;
            $encodeName = iconv("UTF-8","GB2312//IGNORE",$filename); 
            $model->image->saveAs(''.$encodeName);
            $this->redirect(array('show','url'=>$filename));
        }
        $this->render('create', array('model'=>$model));
	}
	
	public function actionShow()
	{
		$url = $_GET['url'];
		if (isset($url)) {
			$this->render('show', array('url'=>$url));
		} else {
			$this->redirect(array('create'));
		}
	}
	
	
}